<?php

use Liriope\Component\Json;

class HeroModule extends LiriopeModule {

    public function random($vars=NULL) {
        global $module;

        $dir = "/images/gallery/";

        if($heros_file = load::exists('heros.json', c::get('root.web') . '/images/gallery')) {
            $json = json_decode(f::read($heros_file));
            $heros = $json->heros;
            $img = $heros[array_rand($heros)];
        }

        $module->result = $dir . $img;
    }
}
